#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//intersection
void intersection(int a[],int size_a,int b[],int size_b)
{
    if(size_a<=0||size_b<=0) cout<<"NULL"<<endl;
    int i=0,j=0;
    while(i<size_a&&j<size_b)
    {
        if(a[i]==b[j])
        {
             cout<<a[i]<<" ";
             i++;
             j++;
        }
        else if(a[i]<b[j]) i++;
        else j++;
    }
}
int main()
{
    int a[] = {102,30,4,13,4,52,5,8,1,9,9};
    int b[] = {4,52,9,9,12,8};
    vector<int> x(a,a+11);
    vector<int> y(b,b+6);
    vector<int> result(20);
    vector<int>::iterator it;
    vector<int>::iterator it_x;
    vector<int>::iterator it_y;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    it_x = unique(x.begin(),x.end());
    it_y = unique(y.begin(),y.end());
    x.resize(it_x-x.begin());
    y.resize(it_y-y.begin());
    it = set_intersection(x.begin(),x.end(),y.begin(),y.end(),result.begin());  // STL Alogorithm
    for(vector<int>::iterator i=result.begin();i!=it;i++)
    {
        cout<<*i<<" "<<endl;
    }
}
